﻿// Copyright (c) 2007-2021 西安交通信息投资营运有限公司 版权所有
// 作者:吕艳阳

using System;
using System.ComponentModel.DataAnnotations;
using System.Windows.Forms;
using XCI.Core;

namespace XCI.Sys
{
    public class FormProviderInfo
    {
        /// <summary>
        /// 编码
        /// </summary>
        [Display(Name = "编码")]
        public string Code { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [Display(Name = "名称")]
        public string Name { get; set; }

        /// <summary>
        /// 实现类
        /// </summary>
        [Display(Name = "实现类")]
        public string Provider { get; set; }

        /// <summary>
        /// 参数
        /// </summary>
        [Display(Name = "参数")]
        public SMap Args { get; set; }
    }

    public class FormInfo
    {
        /// <summary>
        /// 编码
        /// </summary>
        [Display(Name = "编码")]
        public string Code { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [Display(Name = "名称")]
        public string Name { get; set; }

        /// <summary>
        /// 窗体实例
        /// </summary>
        public Form FormInstance { get; set; }

        public FormInfo()
        {
            
        }
        public FormInfo(Form instance)
        {
            FormInstance = instance ?? throw new ArgumentNullException(nameof(instance));
            Code = instance.Name;
            Name = instance.Text;
        }

        public FormInfo(Form instance,string name):this(instance)
        {
            Name = name;
        }

        public FormInfo(Form instance, string name,string code) : this(instance, name)
        {
            Code = code;
        }
    }
}